﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <link href="css/test-css/test.css" rel="stylesheet" />
    <script>
        function onTest() {
            var txt = document.getElementById("txt1");
            txt.value = "aaaa";
            var e = new KeyboardEvent("keypress", { keyCode: 13 });
            txt.dispatchEvent(e);
        }

        function onKps() {
            alert("fire")
        }
    </script>
</head>
<body>
<input type="button" value="按钮" onclick="onTest()"/>
<textarea id="txt1" onkeypress="onKps()"></textarea>
</body>
</html>